package pacBiopackage;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;


public class PacBioReadVCF extends PacBioSNPLineReader {

	
	public PacBioReadVCF(String fileName) throws FileNotFoundException 
	{
		super(fileName);
	}
	
	public List<String> next() throws IOException
	{
		StringTokenizer st = new StringTokenizer(rac.readLine()," ;\t");
		List<String> output = new ArrayList<String>();
		while(st.hasMoreTokens())
		{
			output.add(st.nextToken());
		}
		return output;
	}
	
	public boolean isIndel(List<String> line)
	{
		if(line.get(7).equals("INDEL"))
		{
			return true;
		}
		return false;
	}
	
	public String getRef(List<String> line)
	{
		return line.get(3).trim();
	}
	
	public List<String> getSNP(List<String> line)
	{
		StringTokenizer st= new StringTokenizer(line.get(4).trim(),",");
		List<String> output = new ArrayList<String>();
		while(st.hasMoreElements())
		{
			output.add(st.nextToken());
		}
		return output;
	}
	
	public Integer getDiff(List<String>line)
	{
		return Integer.valueOf(line.get(3).length())-Integer.valueOf(line.get(4).length());
	}
	
	public Integer getType(List<String>line)
	{
		int dif= Integer.valueOf(line.get(3).length())-Integer.valueOf(line.get(4).length());
		if(dif==0)
		{
			return 0; //SNP
		}
		else if(dif>0)
		{
			return 1; //deletion
		}
		else if(dif<0)
		{
			return 2; //insert
		}
		else return 3; //error
	}
	
	public Integer getPosition(List<String> line)
	{
		return Integer.valueOf(line.get(1));
	}
	
	public String getChr(List<String>line)
	{
		return line.get(0);
	}
	
}
